package com.czk.servcie.impl;

import com.czk.mapper.OperateLogMapper;
import com.czk.model.TbOperateLog;
import com.czk.servcie.OperateLogService;
import com.czk.util.IdWorker;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/10/21 15:43
 */
@Service
public class OperateLogServiceImpl implements OperateLogService {
    @Resource
    private OperateLogMapper operateLogMapper;
    @Resource
    private IdWorker idWorker;

    @Override
    public void insert(TbOperateLog operateLog) {
        // 获取分布式id
        long id = idWorker.nextId();
        operateLog.setId(id);
        operateLogMapper.insert(operateLog);
    }

    @Override
    public Page search(Map<String, String> searchMap, Integer pageInteger, Integer size) {
        PageHelper.startPage(pageInteger, size);
        List<TbOperateLog> list = operateLogMapper.search(searchMap);
        return (Page) list;
    }
}
